package com.fdd.op.demo;

import com.fdd.op.sdk.ApiException;
import com.fdd.op.sdk.DefaultFddClient;
import com.fdd.op.sdk.constants.Constants;
import com.fdd.op.sdk.internal.token.FddTokenStore;
import com.fdd.op.sdk.internal.token.stroe.CacheTokenStoreImpl;
import com.fdd.op.sdk.internal.util.json.JSONWriter;
import com.fdd.op.sdk.request.api.verify.person.ChangeRequest;
import com.fdd.op.sdk.response.api.verify.person.ChangeResponse;

import java.text.MessageFormat;

public class Test {

    private static final String serverUrl = "http://local-op2.fabigbig.com:6442";
    private static final String appId = "721522";
    private static final String appKey = "hVpnGJPciVuAc1VXJk9CV7mbZCZejdaO";

    public static void main(String[] args) throws ApiException {

        JSONWriter writer = new JSONWriter(false, true);
        FddTokenStore tokenStore = new CacheTokenStoreImpl();
        DefaultFddClient fddClient = new DefaultFddClient(serverUrl, appId, appKey, Constants.AUTH_OAUTH, 1000, 30000);
        fddClient.tokenStore(tokenStore);
        ChangeRequest request = new ChangeRequest();
        request.setVerifiedWay(1);
        request.setNotifyUrl("http://127.0.0.1/");
        request.setName("123456");


        ChangeResponse response = fddClient.execute(request);
        System.out.println(MessageFormat.format("code:{0}, message:{1}", response.getCode(), response.getMessage()));
        if(response != null && "0".equals(response.getCode())){
            System.out.println(writer.write(response.getData()));
        }
    }

}
